package com.fling.screen;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.Texture.TextureWrap;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.fling.Constants;
import com.fling.Locator;

public class BackgroundManager implements Constants {

	private int COUNTX, COUNTY;
	private Texture background;
	private Texture backgroundEasy, backgroundHard;
	private float position;

	public float SPEED = 15f;

	public BackgroundManager() {
		backgroundEasy = new Texture(BACKGROUND_EASY);
		backgroundHard = new Texture(BACKGROUND_HARD);
		position = 0;
		COUNTX = (int) ((float) Gdx.graphics.getWidth() / (float) backgroundEasy.getWidth() * 2) + 1;
		COUNTY = (int) ((float) Gdx.graphics.getHeight() / (float) backgroundEasy.getHeight() * 2) + 1;
	}

	public void render(SpriteBatch uiBatch) {
		uiBatch.draw(background, 0, position, background.getWidth() * COUNTX, background.getHeight() * COUNTY, 0, COUNTY, COUNTX, 0);
	}

	public void update(float delta) {

	}

	public void switchDifficulty() {
		if (Locator.difficulty == Locator.HARD) {
			background = backgroundHard;
		} else {
			background = backgroundEasy;
		}
		background.setWrap(TextureWrap.Repeat, TextureWrap.Repeat);
	}
}
